load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("//bazel:defs.bzl", "rust_ic_test")

DEPENDENCIES = [
    # Keep sorted.
    "//rs/config",
    "//rs/monitoring/logger",
    "//rs/monitoring/metrics",
    "//rs/protobuf",
    "//rs/registry/routing_table",
    "//rs/registry/subnet_type",
    "//rs/replicated_state",
    "//rs/state_layout",
    "//rs/state_manager",
    "//rs/sys",
    "//rs/types/types",
    "//rs/utils",
    "@crate_index//:clap",
    "@crate_index//:hex",
    "@crate_index//:prost",
    "@crate_index//:slog",
    "@crate_index//:slog-term",
]

MACRO_DEPENDENCIES = []

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/state_machine_tests",
    "@crate_index//:tempfile",
]

MACRO_DEV_DEPENDENCIES = []

ALIASES = {}

rust_library(
    name = "state_tool_lib",
    srcs = glob(
        ["src/**/*.rs"],
        exclude = ["src/main.rs"],
    ),
    aliases = ALIASES,
    crate_name = "ic_state_tool",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.1.0",
    visibility = ["//rs/recovery/subnet_splitting:__subpackages__"],
    deps = DEPENDENCIES,
)

rust_binary(
    name = "state-tool",
    srcs = ["src/main.rs"],
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEPENDENCIES,
    visibility = [
        "//rs:release-pkg",
        "//rs:system-tests-pkg",
    ],
    deps = DEPENDENCIES + [":state_tool_lib"],
)

rust_ic_test(
    name = "state_tool_test",
    aliases = ALIASES,
    crate = ":state_tool_lib",
    proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_ic_test(
    name = "state_tool_integration_test",
    srcs = ["src/main.rs"],
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES + [":state_tool_lib"],
)
